import java.io.IOException;
import java.util.HashMap;

public class TcpDictServer extends TcpEchoServer{

    private HashMap<String, String> dict = new HashMap<>();

    public TcpDictServer(int port) throws IOException {
        super(port);

        dict.put("cat", "小猫");
        dict.put("dog", "小狗");
        //.......
    }

    @Override
    public String process(String request) {
        return dict.getOrDefault(request, "没有查到该单词!");
    }

    public static void main(String[] args) throws IOException {
        TcpDictServer tcpDictServer = new TcpDictServer(6666);
        tcpDictServer.start();
    }
}
